/*
 * GMatchResult.java
 * Created on 13 janv. 2008
 *
 * Glacéo Internet Platform
 * http://sourceforge.net/projects/chm/
 *
 * Copyright (c) 2005-2008, Jan Janke (VirtualHockey Project)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hockeo.vhbase.data.helper;

/**
 * Represents the outcome of a match.
 *
 * @version $Id$
 * @author jjanke
 */
public enum GMatchResult
{
  VICTORY( 3 ),

  VICTORY_AFTER_SHOOTOUT( 2 ),

  LOSS_AFTER_SHOOTOUT( 1 ),

  LOSS( 0 );

  final private int d_nNumPoints;

  /**
   * Creates a new GMatchResult constant.
   *
   * @param nNumPoints the number of points awarded for the given result
   */
  private GMatchResult( final int nNumPoints )
  {
    d_nNumPoints = nNumPoints;
  }

  /**
   * Returns the number of points awarded for the given result.
   */
  public int getNumPoints()
  {
    return d_nNumPoints;
  }

  /**
   * Returns the opposite result. I.e. for a win after shootout, a loss after shootout is
   * returned etc.
   */
  public GMatchResult getOppositeResult()
  {
    switch ( this )
    {
      case VICTORY:
        return LOSS;

      case VICTORY_AFTER_SHOOTOUT:
        return LOSS_AFTER_SHOOTOUT;

      case LOSS:
        return VICTORY;

      case LOSS_AFTER_SHOOTOUT:
        return VICTORY_AFTER_SHOOTOUT;

      default:
        throw new IllegalStateException( "Result " + this.name() + " has no opposite result." );
    }
  }
}
